feat(reports): async attestation render + report.ready event (B3a)#646
Merged
Conversation
Move attestation bulk-face rendering off the request path and emit a report.ready event - the first producer of the in-app notification bell. - eventbus: new EventKindReportReady (report.ready) + ReportReady event (snapshot id, kind, rendered faces, generating principal), added to the AllEventKinds closed set. - report/job.go: a report.render job (RenderJobType + RenderPayload) and a RenderProcessor. Generate(attestation), when async is enabled (WithAsyncRender), marks the bulk faces (csv/oscal_sar/pdf) 'pending' and enqueues the job, returning immediately; the executive summary stays synchronous. The processor renders each face via Export (flipping 'pending' -> 'ready'; a render error marks the face 'failed' and fails the job for retry), completes the job, and publishes ReportReady. - worker: a ReportRenderer interface + WithReportProcessor + a 'report.render' dispatch case (interface-typed so worker does not import report). server: WithReportWorker registers it on the in-process worker. - main.go: build the report service WithAsyncRender + a RenderProcessor over the bus, and register both. Async is an optimization, not a correctness gate: Export stays the lazy fallback, so a download arriving before the job runs still renders inline; enqueue failures are logged and do not fail Generate. Spec api-reports v1.10.0: C-16 + AC-22 (DB test: pending faces + queued job -> processor -> ready faces + completed job + ReportReady event). eventbus AC-07 closed-set test updated for the new kind.
b69dc02 to
6ffae49
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase B3a moves attestation bulk-face rendering off the request path and emits a
report.readyevent — the first producer of the in-app notification bell.What changes
EventKindReportReady(report.ready) +ReportReadyevent (snapshot id, kind, rendered faces, generating principal), added to theAllEventKindsclosed set.report/job.go: areport.renderjob (RenderJobType+RenderPayload) and aRenderProcessor.Generate(attestation), when async is enabled (WithAsyncRender), marks the bulk faces (csv/oscal_sar/pdf)pendingand enqueues the job, returning immediately; the executive summary stays synchronous (tiny rollup). The processor renders each face viaExport(flippingpending → ready; a render error marks the facefailedand fails the job for retry), completes the job, and publishesReportReady.ReportRendererinterface +WithReportProcessor+ areport.renderdispatch case (interface-typed soworkerdoesn't importreport). server:WithReportWorkerregisters it on the in-process worker. main.go: builds the report serviceWithAsyncRender+ aRenderProcessorover the bus.Async is an optimization, not a correctness gate:
Exportstays the lazy fallback, so a download arriving before the job runs still renders inline; enqueue failures are logged and don't failGenerate.How the bell consumes it (for later — B3c)
ReportReadyflows through the existing generic SSE bridge automatically (it marshals any subscribed event). The frontend notification bell (still stubbed) is the remaining B3c slice and needs product decisions before building.Spec / tests
api-reportsv1.10.0: new C-16 + AC-22 (DB test: pending faces + queued job →RenderProcessor→ ready faces + completed job + aReportReadyevent with the snapshot/kind/faces/principal). The eventbus AC-07 closed-set test updated for the new kind.gofmtsilent,go vetclean,go build ./...clean;specter check111 specs structural + 0 annotation errors;go test ./internal/report/ ./internal/eventbus/ ./internal/worker/green.Validation